﻿using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.StorageClient;

namespace XamlingCore.AzureHelper
{
    public class AzureTableHelper
    {
        private CloudStorageAccount cloudStorageAccount;
        private CloudTableClient client;

        private string tableName;

        public AzureTableHelper(string tableName)
        {
            this.TableName = tableName;
            CloudStorageAccount = AzureCommon.GetStorageAccount();
            Client = CloudStorageAccount.CreateCloudTableClient();
            
            Client.CreateTableIfNotExist(tableName);
        }

        public CloudTableClient Client
        {
            get { return client; }
            set { client = value; }
        }

        public CloudStorageAccount CloudStorageAccount
        {
            get { return cloudStorageAccount; }
            set { cloudStorageAccount = value; }
        }

        public string TableName
        {
            get { return tableName; }
            set { tableName = value; }
        }
    }
}
